package graph.day16;

public class Leetcode_55 {

    public boolean canJump(int[] nums) {
        int[] dp = new int[nums.length];
        dp[0] = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (dp[i] >= nums.length) return true;
            if (dp[i - 1] >= i) {
                dp[i] = Math.max(dp[i - 1], i + nums[i]);
            } else {
                return false;
            }
        }
        return true;
    }
}
